package com.aier.src.action.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.StrutsStatics;
import com.aier.common.common.CommonSession;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class CheckAdminLoadInterceptor extends AbstractInterceptor {

	/**
	 * 
	 */
    private static final long serialVersionUID = 1L;
	

    @Override
    public String intercept(ActionInvocation invocation) throws Exception {
        ActionContext actionContext = invocation.getInvocationContext();
        HttpServletRequest request = (HttpServletRequest) actionContext
            .get(StrutsStatics.HTTP_REQUEST);
        HttpSession session=request.getSession();
//        System.out.println(session.getAttribute(CommonSession.SESSION_ACCOUNT));
        //首先判断session，查找是否登录成功，通过拦截器
        if (session != null && session.getAttribute(CommonSession.SESSION_ACCOUNT) != null) {
            return invocation.invoke();
        }
        return "nologin";
    }
    
    
}


